﻿#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;

int main()
{
    //读图
    Mat src=imread("G:\\VS_projects\\Practice_opengl\\OpenCV_Practice\\03.jpg");
    if (!src.data)
    {
        cout << "no image!" << endl;
        return -1;
    }
    imshow("src_image", src);

    //自定义红色图                        B---G---R
    Mat red_img(100, 100, CV_8UC3, Scalar(0, 0, 255));
    imshow("自定义图", red_img);
    //图片某一点赋像素值
   //单通道
   //int gray_num0_0= m.at<uchar>(0, 0);
   //int gray_num0_1= m.at<uchar>(0, 1);
   //3通道
   int clo_num_b = red_img.at<Vec3b>(0, 0)[0];
   int clo_num_g = red_img.at<Vec3b>(0, 0)[1];
   int clo_num_r = red_img.at<Vec3b>(0, 0)[2];
    waitKey(0);
    return 0;
}

